<template>
  <div class="container">
    <div class="title">个人信息</div>
    <div class="main">
      <div class="left">
        <div>
          <img src="@/static/images/common/avatar.jpg" alt="" />
        </div>
      </div>
      <div class="right">
        <el-card>
          <template #header>
            <div class="card-header">
              <p>基础资料</p>
              <p @click="isShowDialog = true">修改信息</p>
            </div>
          </template>
          <div class="card-info">
            <p>账号名：{{ user.userName }}</p>
            <p>性别：{{ user.sex }}</p>
            <p>生日：{{ user.birth }}</p>
            <p class="title">高级设置</p>
            <p>账号所属地区：中国</p>
          </div>
        </el-card>
      </div>
    </div>
    <el-dialog v-model="isShowDialog" title="修改个人信息" width="360px">
      <el-form :model="user">
        <el-form-item label="账号名：" label-width="90px">
          <el-input v-model="user.userName" autocomplete="off" />
        </el-form-item>
        <el-form-item label="性别：" label-width="90px">
          <el-input v-model="user.sex" autocomplete="off" />
        </el-form-item>
        <el-form-item label="生日：" label-width="90px">
          <el-input v-model="user.birth" autocomplete="off" />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="isShowDialog = false">取消</el-button>
          <el-button type="primary" @click="isShowDialog = false"
            >确认</el-button
          >
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, toRefs } from 'vue';

export default defineComponent({
  setup() {
    const state = reactive({
      isShowDialog: false,
      user: {
        userName: 'admin',
        sex: '女',
        birth: '2000-03-09',
      },
    });
    return {
      ...toRefs(state),
    };
  },
});
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  padding: 62px 33px;
  border: 1px solid #ccc;

  .title {
    border-bottom: 1px solid #ddd;
    font-size: 18px;
    padding-bottom: 20px;
  }

  .main {
    height: calc(100% - 45px);
    display: flex;
    .left {
      width: 180px;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;

      div {
        width: 102px;
        height: 102px;
        border-radius: 50%;
        border: 1px solid #ddd;
        padding: 2px;

        img {
          width: 100px;
          height: 100px;
          border-radius: 50%;
        }
      }
    }
    .right {
      padding-top: 20px;
      padding-left: 20px;
      height: 100%;
      flex-grow: 1;

      .card-header {
        display: flex;
        justify-content: space-between;

        p {
          &:first-child {
            font-size: 18px;
            font-weight: 700;
          }
          &:last-child {
            font-size: 14px;
            color: red;
            cursor: pointer;
          }
        }
      }
      .card-info {
        p {
          padding: 8px 0px;
          border-bottom: 1px solid #ddd;
        }
        .title {
          font-size: 18px;
          font-weight: 700;
        }
      }
    }
  }
}
</style>
